﻿using System;

namespace TempEmployees.BLL.Validations
{
    public class MonthlyHours
    {
        private int m_monthlyHours;

        public int Hours { get { return m_monthlyHours; } }

        public MonthlyHours(int monthlyHours)
        {
            m_monthlyHours = monthlyHours;
            if (!IsValid(m_monthlyHours)) throw new ValidationErrorException();
        }

        public static bool IsValid(int monthlyHours)
        {
            return monthlyHours > 0;
        }

        public static bool IsValid(object monthlyHours)
        {
            try
            {
                return IsValid(int.Parse(monthlyHours.ToString()));
            }
            catch
            {
                return false;
            }
        }
    }
}